package o;

import com.google.android.exoplayer2.ParserException;
import java.io.EOFException;
import java.io.IOException;

final class afp {
    private static final int ॱˊ = anr.ᐝ("OggS");
    public int ʻ;
    public long ʼ;
    public int ʽ;
    public int ˊ;
    public long ˋ;
    public long ˎ;
    public long ˏ;
    private final anc ͺ = new anc(255);
    public int ॱ;
    public final int[] ॱॱ = new int[255];
    public int ᐝ;

    afp() {
    }

    public void ˊ() {
        this.ॱ = 0;
        this.ˊ = 0;
        this.ˏ = 0;
        this.ˎ = 0;
        this.ˋ = 0;
        this.ʼ = 0;
        this.ʽ = 0;
        this.ʻ = 0;
        this.ᐝ = 0;
    }

    public boolean ˊ(adv o_adv, boolean z) throws IOException, InterruptedException {
        int i = 0;
        this.ͺ.ˏ();
        ˊ();
        int i2 = (o_adv.ॱ() == -1 || o_adv.ॱ() - o_adv.ˎ() >= 27) ? true : 0;
        if (i2 == 0 || !o_adv.ˎ(this.ͺ.ˏ, 0, 27, true)) {
            if (z) {
                return false;
            }
            throw new EOFException();
        } else if (this.ͺ.ˋॱ() == ((long) ॱˊ)) {
            this.ॱ = this.ͺ.ʽ();
            if (this.ॱ == 0) {
                this.ˊ = this.ͺ.ʽ();
                this.ˏ = this.ͺ.ʻॱ();
                this.ˎ = this.ͺ.ॱˊ();
                this.ˋ = this.ͺ.ॱˊ();
                this.ʼ = this.ͺ.ॱˊ();
                this.ʽ = this.ͺ.ʽ();
                this.ʻ = this.ʽ + 27;
                this.ͺ.ˏ();
                o_adv.ˎ(this.ͺ.ˏ, 0, this.ʽ);
                while (i < this.ʽ) {
                    this.ॱॱ[i] = this.ͺ.ʽ();
                    this.ᐝ += this.ॱॱ[i];
                    i++;
                }
                return true;
            } else if (z) {
                return false;
            } else {
                throw new ParserException("unsupported bit stream revision");
            }
        } else if (z) {
            return false;
        } else {
            throw new ParserException("expected OggS capture pattern at begin of page");
        }
    }
}
